﻿@model RegularSearchViewModel
@{
    ViewBag.Title = "Kelper - Search";
}

<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>

<h2>
    Search our tasteful database
    @Html.ActionLink("I want to search by ingredients", "index")
</h2>

@using (Html.BeginForm(null, null, FormMethod.Get))
{
    <div>
        <label class="subtle" for="q">Enter your search keywords</label><br />
        @Html.TextBox("q", null,
                      new { data_val = "true", data_val_required = "*", placeholder = "Enter keywords", style = "width:50%" })
        <input id="search-submit" type="submit" value="Search!" />
    </div>
}

@if (Model != null)
{
    if (!Model.Recipes.Any()) {
        <p class="error">No recipes found!</p>
    } else {
        foreach (var r in Model.Recipes) {
            @Html.DisplayFor(m => r.Recipe)
        }
        @Html.PageLinks(Model.TotalPages, Model.CurrentPage, x => Url.Action(null, new { q = Model.Query, page = x }))
    }
}